package com.atguigu.common.validator;


import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;
import java.util.Set;

public class listValueConstraint implements ConstraintValidator<listValue,Integer> {
    private Set<Integer> vals=new HashSet<>();
    @Override
    public void initialize(listValue constraintAnnotation) {
        int[] ints = constraintAnnotation.vals();
        for (int i : ints) {
            vals.add(i);
        }

    }

    @Override
    public boolean isValid(Integer integer, ConstraintValidatorContext constraintValidatorContext) {
        return vals.contains(integer);
    }
}
